// Copyright (C) 2005 Taylor L. Riché <riche@cs.utexas.edu>
//  
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software 
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// 	$Id: PhysInterfaceSix.hh 949 2008-09-23 21:29:59Z djwhitebread $	
//

#ifndef PHYSINTERFACESIX_HH
#define PHYSINTERFACESIX_HH

#include <assert.h>
#include <pthread.h>
#include <sched.h>
#include <sys/select.h>
#include <sys/time.h>
#include <fcntl.h>
#include <sys/file.h>


#include <string>
#include <iostream>
#include <queue>

#include <errno.h>

#include <sys/socket.h>
#include <netpacket/packet.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <sys/ioctl.h>

#include <linux/filter.h>

#include <lagniappe/RequestDevice.h>
#include <lagniappe/RCon.h>
#include <lagniappe/RData.h>

#include <sysmodel/Synchronized.hh>

#include "Packet.hh"
#include "PhysInterface.hh"

namespace requestDevices {

typedef int socket_t;

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

void * startNICSix(void * arg);

#ifdef __cplusplus
}
#endif /* __cplusplus */

class PhysInterfaceSix : public lagniappe::RequestDevice, Synchronized
{
  unsigned int intfNum;
  pthread_t coreThread;
  socket_t coreSocket;
  sockaddr_ll coreFrom;
  bool fromSet;
  std::string intfName;
  bool sysReady;
  static int procNum;
  uint32_t rcvCount, sndCount;
public:
  PhysInterfaceSix(std::string intf);
  virtual void list();
  void process();
  //virtual void processData(lagniappe::RData * const pkt);
  virtual void run(lagniappe::RCon * rcon);
  virtual void start();
};
}
#endif // PHYSINTERFACE_HH
